﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CRM.Database.Model.Customers>" %>
<%@ Import Namespace="CRM.Database.Model" %>
<%@ Import Namespace="CRM.Resourses" %>

<% Html.DevExpress().GridView(settings =>
                                    {
                                        settings.Name = "gdLegalEntities";
                                        settings.KeyFieldName = "IdLegalEntity";

                                        settings.CallbackRouteValues =
                                          new { Controller = "Customers", Action = "CustomerLegalEntities_Edit", customerId = Model.IdCustomer };
                                        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Customers", Action = "CustomerLegalEntitiesUpdate", customerId = Model.IdCustomer };
                                        settings.SettingsEditing.AddNewRowRouteValues = new { Controller = "Customers", Action = "CustomerLegalEntitiesAdd", customerId = Model.IdCustomer };
                                        settings.SettingsEditing.DeleteRowRouteValues = new { Controller = "Customers", Action = "CustomerLegalEntitiesDelete", customerId = Model.IdCustomer };

                                        settings.Columns.Add(column =>
                                       {
                                           column.Caption = Resourses.LegalEntityName;
                                           column.FieldName = "Name";

                                       });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.LegalEntityNUmberInSAP;
                                            column.FieldName = "NumberInSAP";
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.OwnershipPattern;
                                            column.FieldName = "IdOwnershipPattern";
                                            column.ColumnType = MVCxGridViewColumnType.ComboBox;

                                            var comboBoxProperties = column.PropertiesEdit as ComboBoxProperties;
                                            if (comboBoxProperties != null)
                                            {
                                                var col = new OwnershipsPatternsCollection();
                                                comboBoxProperties.DataSource =
                                                    col.OwnershipsPatternsList;
                                                comboBoxProperties.TextField = "LocalizedName";
                                                comboBoxProperties.ValueField = "IdOwnershipPattern";
                                                comboBoxProperties.ValueType = typeof(int);
                                            }
                                        });

                                        settings.Columns.Add(column =>
                                        {
                                            column.Caption = Resourses.IsForContract;
                                            column.FieldName = "IsForContract";
                                            column.ColumnType = MVCxGridViewColumnType.CheckBox;
                                        });
                                        
                                     //   settings.Columns.Add("Name");
                                        
                                        settings.SettingsPager.PageSize = 20;

                                        settings.CommandColumn.Visible = true;
                                        settings.CommandColumn.NewButton.Visible = true;
                                     //   settings.CommandColumn.DeleteButton.Visible = true;
                                        settings.CommandColumn.EditButton.Visible = true;
                                        settings.SettingsBehavior.ConfirmDelete = true;
                                        settings.Settings.ShowFilterRow = false;


                                      //  settings.Settings.ShowVerticalScrollBar = true;
                                        //settings.Settings.VerticalScrollableHeight = 350;
                                        //settings.Settings.VerticalScrollBarStyle = GridViewVerticalScrollBarStyle.Virtual;
                                        settings.ControlStyle.Paddings.Padding = Unit.Pixel(0);
                                        settings.ControlStyle.Border.BorderWidth = Unit.Pixel(0);
                                        settings.ControlStyle.BorderBottom.BorderWidth = Unit.Pixel(1);

                                        settings.SettingsEditing.Mode = GridViewEditingMode.EditFormAndDisplayRow;
                                      //  settings.Width = Unit.Percentage(100);
                        
                                       
                                        
                                    }

    ).Bind(Model.LegalEntities.ToList()).Render();               %>